package jxerializeml.errors;

import org.xml.sax.SAXParseException;

/**
 * General class for all exceptions in the JXerializeML.
 * 
 * @author Tomáš Zíma
 */
@SuppressWarnings("serial")
public class JXerializeMLError extends SAXParseException {
	/** Original exception which was thrown. */
	private Exception originalException = null;
	
	/**
	 * Saves error message and original exception which was thrown.
	 * 
	 * @param errorMessage
	 *     String describing the error.
	 *     
	 * @param originalException
	 *     Exception, which was originally thrown. May be null if any.
	 */
	public JXerializeMLError(String errorMessage, Exception originalException) {
	    super(errorMessage, null);
    }

	/**
	 * Saves error message.
	 * 
	 * @param errorMessage
	 *     String describing the error.
	 */	
	public JXerializeMLError(String errorMessage) {
	    super(errorMessage, null);
    }

	/**
	 * Saves original exception which was thrown.
	 * 
	 * @param originalException
	 *     Exception, which was originally thrown. May be null if any.
	 */
	public void setOriginalException(Exception originalException) {
		this.originalException = originalException;
	}
	
	/**
	 * @return
	 *     Exception, which was originally thrown. May be null if any!
	 */	
	public Exception getOriginalException() {
		return originalException;
	}
}
